Method, apparatus and electronic device for processing image

ABSTRACT

The application discloses a method, an apparatus and an electronic device for processing an image. The method includes: acquiring an image with a first rendering style and an image with a second rendering style; generating at least one first intermediate gradient image based on the image with the first rendering style and the image with the second rendering style; wherein the at least one first intermediate gradient image comprises an image in a gradient process from the image with the first rendering style to the image with the second rendering style; and generating a first gradient video based on the image with the first rendering style, the at least one first intermediate gradient image, and the image with the second rendering style.

CROSS-REFERENCE TO RELATED APPLICATIONS

This application is a continuation of U.S. patent application Ser. No.16/972,475, filed on Dec. 4, 2020, which is a continuation ofInternational Application No. PCT/CN2019/098011, filed on Jul. 26, 2019,which is based on and claims priority under 35 U.S.C. 119 to ChinesePatent Application No. 201811142166.1, filed with the China NationalIntellectual Property Administration on Sep. 28, 2018 and entitled“METHOD, APPARATUS, ELECTRONIC DEVICE, AND STORAGE MEDIUM FOR PROCESSINGIMAGE”, which is incorporated herein by reference in its entirety.

FIELD

This application relates to the field of computer technologies, inparticular to a method, an apparatus, and an electronic device forprocessing an image.

BACKGROUND

With the development of technologies, watching videos has becomepeople's main entertainment manner. To improve experience of watchingvideos, more and more users like to watch gradient videos shot throughtime-lapse photography, for example, a gradient video from day to night,or a gradient video from dawn to morning.

However, in a related technology, if a user wants to acquire a gradientvideo, the user requires to speed a long time in continuously shooting avideo of a location by using a camera, leading to low efficiency ofacquiring a gradient video.

SUMMARY

According to a first aspect of this application, a method for processingan image is provided, where the method includes:

acquiring an image with a first rendering style and an image with asecond rendering style;

generating at least one first intermediate gradient image based on theimage with the first rendering style and the image with the secondrendering style; wherein the at least one first intermediate gradientimage comprises an image in a gradient process from the image with thefirst rendering style to the image with the second rendering style; and

generating a first gradient video based on the image with the firstrendering style, the at least one first intermediate gradient image, andthe image with the second rendering style.

According to a second aspect of this application, an electronic deviceis provided, where the electronic device includes:

a processor; and a memory configured to store an instruction executed bythe processor; where in response to the instruction being executed, theprocessor is configured to:

acquire an image with a first rendering style and an image with a secondrendering style;

generate at least one first intermediate gradient image based on theimage with the first rendering style and the image with the secondrendering style; wherein the at least one first intermediate gradientimage comprises an image in a gradient process from the image with thefirst rendering style to the image with the second rendering style; and

generate a first gradient video based on the image with the firstrendering style, the at least one first intermediate gradient image, andthe image with the second rendering style.

According to a third aspect of this application, a non-temporarycomputer readable storage medium is provided, where in response to aninstruction in the storage medium being executed by a processor of anelectronic device, the electronic device is enabled to perform themethod for processing the image described in the first aspect.

According to a fourth aspect of this application, a computer programproduct is provided, where in response to an instruction in the computerprogram product being executed by a processor of an electronic device,the electronic device is enabled to perform the method for processingthe image described in the first aspect.

It should be understood that the foregoing general descriptions and thefollowing detailed descriptions are merely used as an example and usedfor explanation, and cannot limit this application.

BRIEF DESCRIPTION OF THE DRAWINGS

The accompanying drawings herein are incorporated into thisspecification and form one part of this specification, show embodimentsconforming to this application, and are used, together with thisspecification, to explain the principle of this application.

FIG. 1 illustrates a flowchart of a method for processing an imageaccording to this application.

FIG. 2 illustrates a block diagram of an apparatus for processing animage according to this application.

FIG. 3 illustrates a block diagram of an electronic device according tothis application.

FIG. 4 illustrates a block diagram of an electronic device according tothis application.

DETAILED DESCRIPTION OF THE EMBODIMENTS

The example embodiments are described in detail herein, and the examplesare represented in the accompanying drawings. When the accompanyingdrawings are described below, unless otherwise specified, same numbersin different accompanying drawings represent same or similar elements.Implementations described in the following example embodiments are notall implementations consistent with this application. On the contrary,the implementations are merely examples of apparatuses and methodsdescribed in detail in the claims and consistent with some aspects ofthis application.

FIG. 1 illustrates a flowchart of a method for processing an imageaccording to this application. As shown in FIG. 1, the method is appliedto an electronic device, and the method includes the following steps.

In S101, an image with a first rendering style is acquired.

In this application, when a user is interested in scenery in a location,the user may want to watch a gradient video including the scenery andsimilar to time-lapse photography, for example, a gradient video of thescenery from day to night or a gradient video of the scenery from dawnto morning. In this case, the user does not require to continuouslyshoot a several-hour gradient video of the scenery by using a camera,but may take one image including the scenery by using an electronicdevice, namely, the image with the first rendering style.

Each image has its own rendering style, for example, a green renderingstyle, a blue rendering style, or a red rendering style. The user mayuse a filter when capturing the image including the scenery by using theelectronic device, so that the captured image is an image with arendering style. Alternatively, the user does not use a filter whencapturing the image including the scenery by using the electronicdevice. In this case, the captured image is close to reality, and astyle of the captured image is a no-rendering style. In thisapplication, the no-rendering style is a special rendering style.

In some embodiments, in addition to that the image with the firstrendering style may be taken on site by using the electronic device, theimage with the first rendering style may be further acquired from apre-stored image library, or the image with the first rendering stylemay be downloaded from a network or may be acquired in another manner. Aspecific manner of acquiring the image with the first rendering style isnot limited in this application.

In S102, an image with a second rendering style is acquired based on theimage with the first rendering style and a first preset processingmodel.

In this application, image content of the image with the secondrendering style may be the same as image content of the image with thefirst rendering style.

This step may be implemented in the following three manners. One mannerincludes the following.

11). Receiving the specified second rendering style.

In this application, the gradient video that the user requires toacquire is a gradient video in which images gradually change from thefirst rendering style to another rendering style. Therefore, afteracquiring the first rendering style, the electronic device also requiresto acquire another rendering style, to acquire the gradient video inwhich the images gradually change from the first rendering style toanother rendering style.

The user may specify the second rendering style in the electronicdevice. For example, after capturing the image with the first renderingstyle by using the electronic device, the user may input a request foracquiring a gradient video in the electronic device. After receiving therequest, the electronic device may display a preset plurality ofrendering styles on a screen of the electronic device for the user toselect. After viewing the plurality of rendering styles on the screen ofthe electronic device, the user may select one rendering style, and theelectronic device receives the rendering style selected by the user, anduses the rendering style as the second rendering style.

12). Determining a relationship table of color transformation fortransforming the first rendering style into the second rendering style.

In this application, different rendering styles correspond to differentpieces of color information, and transforming an image with a renderingstyle into an image with another rendering style is essentiallytransforming colors of pixels in the image with a rendering style intocolors corresponding to another rendering style. Therefore, to acquirethe image with the second rendering style based on the image with thefirst rendering style, the relationship table of color transformationfor transforming the first rendering style into the second renderingstyle requires to be determined.

In this application, a plurality of rendering styles are preset, forexample, a green rendering style, a blue rendering style, or a redrendering style. Therefore, for any two rendering styles, a relationshiptable of color transformation for transforming one rendering style intothe other rendering style of the two rendering styles requires to bepreset; and then, the one rendering style, the other rendering style,and the specified relationship table of color transformation formcorresponding entries and are stored in a correspondence among anoriginal rendering style, a target rendering style, and a relationshiptable of color transformation by using the one rendering style as anoriginal rendering style and the other rendering style as a targetrendering style. In addition, a relationship table of colortransformation for transforming the other rendering style into the onerendering style of the two rendering styles requires to be preset; andthen, the other rendering style, the one rendering style, and thespecified relationship table of color transformation form correspondingentries and are stored in the correspondence among an original renderingstyle, a target rendering style, and a relationship table of colortransformation by using the other rendering style as an originalrendering style and the one rendering style as a target rendering style.The foregoing operations are performed for every two other presetrendering styles.

In this way, in this step, the relationship table of colortransformation corresponding to the first rendering style and the secondrendering style may be searched for in the correspondence among anoriginal rendering style, a target rendering style, and a relationshiptable of color transformation by using the first rendering style as anoriginal rendering style and the second rendering style as a targetrendering style.

13). Acquiring first color information of each pixel in the image withthe first rendering style.

Color information of a pixel may be identified by using values of thepixel in a red channel, a green channel, and a blue channel, or may beidentified in another manner. This is not limited in this application.

14). Searching for second color information corresponding to the firstcolor information of each pixel in the relationship table of colortransformation.

The relationship table of color transformation includes two columns. Afirst column stores each piece of first color information correspondingto the first rendering style, a second column stores each piece ofsecond color information corresponding to the second rendering style,and each row stores one piece of first color information correspondingto the first rendering style and one piece of second color informationcorresponding to the second rendering style.

For any pixel, first color information of the pixel may be searched forin the first column of the relationship table of color transformation;and then, second color information corresponding to the first colorinformation of the pixel is searched for in the second column, that is,the second color information in a same row as the first colorinformation of the pixel is searched for. The foregoing operations areperformed for each of the other pixels.

15). Generating the image with the second rendering style based on thesecond color information corresponding to the first color information ofeach pixel.

Pixels in the image with the first rendering style have respectivelocations in the image with the first rendering style. After the secondcolor information corresponding to the first color information of eachpixel is acquired, a blank image of same resolution as the image withthe first rendering style may be generated, locations of the pixels inthe blank image are determined based on the locations of the pixels inthe image with the first rendering style, and the respective locationsof the pixels in the blank image are filled with the second colorinformation corresponding to the first color information of the pixels,to acquire the image with the second rendering style.

Another manner includes the following.

21). Receiving the specified second rendering style.

In this application, the gradient video that the user requires toacquire is a gradient video in which images gradually change from thefirst rendering style to another rendering style. Therefore, afteracquiring the first rendering style, the electronic device also requiresto acquire the another rendering style, to acquire the gradient video inwhich the images gradually change from the first rendering style to theanother rendering style.

The user may specify the second rendering style in the electronicdevice. For example, after capturing the image with the first renderingstyle by using the electronic device, the user may input a request foracquiring a gradient video in the electronic device. After receiving therequest, the electronic device may display a preset plurality ofrendering styles on a screen of the electronic device for the user toselect. After viewing the plurality of rendering styles on the screen ofthe electronic device, the user may select one rendering style, and theelectronic device receives the rendering style selected by the user, anduses the rendering style as the second rendering style.

22). Determining a neural network model for acquiring the image with thesecond rendering style, namely, the above first preset processing model.

In this application, different rendering styles correspond to differentpieces of color information, and transforming an image with a renderingstyle into an image with another rendering style is essentiallytransforming colors of pixels in the image with a rendering style intocolors corresponding to another rendering style.

Therefore, to acquire the image with the second rendering style based onthe image with the first rendering style, the neural network model foracquiring the image with the second rendering style requires to bedetermined. The neural network model is used to process an input image,and output an image with the specified rendering style.

In this application, a plurality of rendering styles are preset, forexample, a green rendering style, a blue rendering style, or a redrendering style.

Therefore, for any rendering style, a neural network model for acquiringan image with the rendering style requires to be pre-trained. Forexample, a preset neural network may be trained by using an annotationimage with the rendering style until all parameters in the preset neuralnetwork converge, to acquire the neural network model for acquiring theimage with the rendering style. Then, the rendering style and thetrained neural network model for acquiring the image with the renderingstyle form corresponding entries, and are stored in a correspondencebetween a rendering style and a neural network model for acquiring animage with the rendering style. The foregoing operations are performedfor each of the other rendering styles.

In this way, in this step, the neural network model corresponding to thesecond rendering style may be searched for in the correspondence betweena rendering style and a neural network model for acquiring an image withthe rendering style.

23). Processing the image with the first rendering style by using theneural network model, to acquire the image with the second renderingstyle.

For example, the image with the first rendering style is input to theacquired neural network model, to acquire the image with the secondrendering style output by the acquired neural network model.

Still another manner includes the following.

31). Acquiring a preset image with the second rendering style.

In this application, the gradient video that the user requires toacquire is a gradient video in which images gradually change from thefirst rendering style to another rendering style. Therefore, afteracquiring the first rendering style, the electronic device also requiresto acquire another rendering style, to acquire the gradient video inwhich the images gradually change from the first rendering style to theanother rendering style.

For example, after capturing the image with the first rendering style byusing the electronic device, the user may input a request for acquiringa gradient video in the electronic device. After receiving the request,the electronic device may display a preset plurality of rendering styleson a screen of the electronic device for the user to select. Afterviewing the plurality of rendering styles on the screen of theelectronic device, the user may select one rendering style, and theelectronic device receives the rendering style selected by the user,uses the rendering style as the second rendering style, and then selectsthe preset image with the second rendering style in preset images withthe preset plurality of rendering styles.

32). Generating a reference image.

An image may be randomly generated as the reference image, for example,a plain white image or an all black image is generated.

33). Performing at least one round of optimal iteration on the referenceimage by using an iterative optimization algorithm, based on the imagewith the first rendering style and the preset image with the secondrendering style; and determining a reference image on which the optimaliteration has been performed as the image with the second renderingstyle, when a difference between a rendering style of the referenceimage and the second rendering style is less than a first presetthreshold and a difference between image content of the reference imageand image content of the image with the first rendering style is lessthan a second preset threshold.

A first image feature of the image with the first rendering style, asecond image feature of the image with the second rendering style, and athird image feature of the reference image may be acquired.

A difference between the first image feature and the third image featureis acquired and is used as a first difference between the image contentof the reference image and the image content of the image with the firstrendering style. A difference between the second image feature and thethird image feature is acquired and is used as a second differencebetween the rendering style of the reference image and the secondrendering style. Color information of pixels in the reference image isadjusted based on the first difference and the second difference andaccording to a preset rule, to acquire the reference image on which theoptimal iteration has been performed.

Then, a fourth image feature of the reference image on which the optimaliteration has been performed is acquired. A difference between the firstimage feature and the fourth image feature is acquired and is used as athird difference between the image content of the reference image onwhich the optimal iteration has been performed and the image content ofthe image with the first rendering style. A difference between thesecond image feature and the fourth image feature is acquired and isused as a fourth difference between the rendering style of the referenceimage on which the optimal iteration has been performed and the secondrendering style. If the fourth difference is less than the first presetthreshold and the third difference is less than the second presetthreshold, the reference image on which the optimal iteration has beenperformed is determined as the image with the second rendering style;otherwise, optimal iteration continues to be performed on the referenceimage on which the optimal iteration has been performed based on theabove steps; and a reference image on which the optimal iteration hasbeen performed is determined as the image with the second renderingstyle when a difference between a rendering style of the reference imageand the second rendering style is less than the first preset threshold,and a difference between image content of the reference image and theimage content of the image with the first rendering style is less thanthe second preset threshold.

In S103, at least one first intermediate gradient image is generatedbased on the image with the first rendering style, the image with thesecond rendering style, and a second preset processing model; and the atleast one first intermediate gradient image includes an image in agradient process from the image with the first rendering style to theimage of the second rendering style.

In this application, this step may be implemented by using the followingprocess, including:

41). For each same location in the image with the first rendering styleand the image with the second rendering style, acquiring first colorinformation of a pixel in the location in the image with the firstrendering style and second color information of a pixel in the locationin the image with the second rendering style; and determining at leastone piece of target color information of a pixel in the location basedon the first color information, the second color information, a presetfirst rendering style coefficient, and a preset second rendering stylecoefficient.

In this application, resolution of the image with the first renderingstyle is the same as resolution of the image with the second renderingstyle. Therefore, for a location of any pixel in the image with thefirst rendering style, there is a pixel in the location in the imagewith the second rendering style.

For any same location in the image with the first rendering style andthe image with the second rendering style, the first color informationof the pixel in the location in the image with the first rendering styleand the second color information of the pixel in the location in theimage with the second rendering style may be acquired, and then the atleast one piece of target color information of the pixel in the locationmay be determined based on the first color information, the second colorinformation, the preset first rendering style coefficient, and thepreset second rendering style coefficient. The foregoing operations areperformed for each of the other same locations in the image with thefirst rendering style and the image with the second rendering style.

When the at least one piece of target color information of the pixel inthe location is determined based on the first color information, thesecond color information, the preset first rendering style coefficient,and the preset second rendering style coefficient, a first product ofthe first color information and the preset first rendering stylecoefficient may be calculated, then a second product of the second colorinformation and the preset second rendering style coefficient may becalculated, and then a first sum of the first product and the secondproduct may be calculated. Then, a second sum of the first colorinformation and the second color information is calculated. Then, aratio of the first sum to the second sum is calculated and is used asthe target color information.

Color information of a pixel may be identified by using values of thepixel in a red channel, a green channel, and a blue channel. Certainly,color information of a pixel may be identified in another manner. Thisis not limited in this application.

42). Generating at least one candidate image based on the at least onepiece of target color information of a pixel in each location.

In this step, a blank image of which resolution is the same as that ofthe image with the first rendering style or a blank image of whichresolution is the same as that of the image with the second renderingstyle may be generated, then a location of each pixel in the blank imageis determined based on a location of the each pixel in the image withthe first rendering style or a location of the each pixel in the imagewith the second rendering style, and then, the location of each pixel inthe blank image is filled with the target color information of the eachpixel, to acquire the candidate image.

43). Determining the at least one first intermediate gradient imagebased on the at least one candidate image.

In some embodiments, the at least one candidate image may be directlydetermined as at least one intermediate gradient image.

In some embodiments, to improve realness of the gradient process fromthe image with the first rendering style to the image with the secondrendering style, generally, local processing requires to be performed onthe intermediate gradient image. For example, usually, lights in abuilding do not require to be turned on during daytime, but require tobe turned on at night.

When an image is transformed into images with different renderingstyles, generally, local processing is performed on intermediategradient images in transformation processes in different manners. Forexample, in a gradient process from day to night, lights in a buildingrequire to be turned on gradually, and the number of lights that areturned on is gradually increased. In a gradient process from dawn tomorning, the lights in the building require to be turned off gradually,and the number of lights that are turned on is gradually decreased.Therefore, local processing requires to be performed on the intermediategradient image, to improve realness of the gradient process. In thiscase, a processing manner is to identify a window of the building andchange color information of the window, to reflect on or off of thelights in the building.

For another example, when a blue rendering style is transformed into ared rendering style or a purple rendering style, generally, colorinformation of pixels is transformed, and there is no need to performlocal processing on an image.

Therefore, whether to perform local processing and how to perform localprocessing are usually determined based on an original rendering styleand a target rendering style.

Therefore, a local processing manner requires to be acquired based onthe first rendering style and the second rendering style, and then theat least one candidate image is processed according to the acquiredlocal processing manner, to acquire the at least one intermediategradient image.

For any two rendering styles, in a process of transforming an image withone of the two rendering styles into an image with the other renderingstyle, a local processing manner of performing local processing on anintermediate gradient image in the process requires to be preset, andthen, the one rendering style, the other rendering style, and thespecified local processing manner form corresponding entries and arestored in a correspondence among an original rendering style, a targetrendering style, and a local processing manner by using the onerendering style as an original rendering style and the other renderingstyle as a target rendering style. In addition, in a process oftransforming the image with the other of the two rendering styles intothe image with the one rendering style, a local processing manner ofperforming local processing on an intermediate gradient image in theprocess requires to be preset, and then, the other rendering style, theone rendering style, and the specified local processing manner formcorresponding entries and are stored in the correspondence among anoriginal rendering style, a target rendering style, and a localprocessing manner by using the other rendering style as an originalrendering style and the one rendering style as a target rendering style.The foregoing operations are performed for every two other presetrendering styles.

In this way, when the local processing manner is acquired based on thefirst rendering style and the second rendering style, the localprocessing manner corresponding to the first rendering style and thesecond rendering style may be searched for in the correspondence amongan original rendering style, a target rendering style, and a localprocessing manner by using the first rendering style as an originalrendering style and the second rendering style as a target renderingstyle.

In some embodiments, to highlight a gradient effect in the gradientprocess from the image with the first rendering style to the image withthe second rendering style, usually, there are at least two firstintermediate gradient images in the gradient process from the image withthe first rendering style to the image with the second rendering style,and an actual quantity may be specifically determined based on arendering style difference between the image with the first renderingstyle and the image with the second rendering style. Details are notdescribed in this application.

The preset first rendering style coefficient includes a differencebetween a preset value and the preset second rendering stylecoefficient. The preset value may be 1 or the like. In this way, thepreset second rendering style coefficient may be constantly increased ata particular increase amplitude, the preset first rendering stylecoefficient is decreased each time the preset second rendering stylecoefficient is increased, and 41) to 43) are performed again after thepreset second rendering style coefficient is increased until the presetsecond rendering style coefficient is the same as the preset value.

According to the method, at least two intermediate gradient images maybe acquired, and for a sequence of acquiring the intermediate gradientimages, a rendering style of an intermediate gradient image that isacquired earlier is closer to the first rendering style, and a renderingstyle of an intermediate gradient image that is acquired later is closerto the second rendering style.

In S104, a first gradient video is generated based on the image with thefirst rendering style, the at least one first intermediate gradientimage, and the image with the second rendering style.

In this application, the image with the first rendering style may beused as an image in a first frame, the image with the second renderingstyle may be used as an image in a last frame, and the at least onefirst intermediate gradient image may be used as an image between theimage with the first rendering style and the image with the secondrendering style, to form the first gradient video.

If there are at least two first intermediate gradient images, a sequenceof the at least two first intermediate gradient images in the firstgradient video is the same as a sequence of acquiring the firstintermediate gradient images.

In this application, the image with the first rendering style isacquired; the image with the second rendering style is acquired based onthe image with the first rendering style and the first preset processingmodel; the at least one first intermediate gradient image is generatedbased on the image with the first rendering style, the image with thesecond rendering style, and the second preset processing model, wherethe at least one first intermediate gradient image includes the image inthe gradient process from the image with the first rendering style tothe image with the second rendering style; and the first gradient videois generated based on the image with the first rendering style, the atleast one first intermediate gradient image, and the image with thesecond rendering style. According to this application, when a userrequires to acquire a gradient video, the user does not require to spenda long time in continuously shooting the gradient video by using acamera, and can acquire the gradient video in the manner in thisapplication only by capturing one image, thereby improving efficiency ofacquiring a gradient video and improving user experience.

Further, sometimes, the user may require to acquire a plurality ofcontinuous gradient effects to further have better gradient experience,for example, a gradient process from the first rendering style to thesecond rendering style and then from the second rendering style to athird rendering style.

Therefore, to bring better gradient experience to the user, in someembodiments, an image with the third rendering style may be acquiredbased on the image with the second rendering style and the first presetprocessing model, where image content of the image with the thirdrendering style may be the same as the image content of the image withthe second rendering style. Then, at least one second intermediategradient image is generated based on the image with the second renderingstyle, the image with the third rendering style, and the second presetprocessing model, where the at least one second intermediate gradientimage includes an image in a gradient process from the image with thesecond rendering style to the image with the third rendering style.Then, a second gradient video is generated based on the image with thesecond rendering style, the at least one second intermediate gradientimage, and the image with the third rendering style. Then, the firstgradient video and the second gradient video are combined into a thirdgradient video. In this way, when the user watches the third gradientvideo, the user can experience the gradient process from the firstrendering style to the second rendering style and the gradient processfrom the second rendering style to the third rendering style, so as tohave better gradient experience, and further improve user experience.For specific implementations of the steps in the embodiments of thisapplication, refer to the foregoing embodiments. Details are notdescribed herein again.

FIG. 2 illustrates a block diagram of an apparatus for processing animage according to this application. Referring to FIG. 2, the apparatusincludes: a first acquiring module 11, configured to acquire an imagewith a first rendering style; a second acquiring module 12, configuredto acquire an image with a second rendering style based on the imagewith the first rendering style and a first preset processing model; afirst generating module 13, configured to generate at least one firstintermediate gradient image based on the image with the first renderingstyle, the image with the second rendering style, and a second presetprocessing model; where the at least one first intermediate gradientimage includes an image in a gradient process from the image with thefirst rendering style to the image with the second rendering style; anda second generating module 14, configured to generate a first gradientvideo based on the image with the first rendering style, the at leastone first intermediate gradient image, and the image with the secondrendering style.

In some embodiments, the second acquiring module 12 includes: a firstacquiring unit, configured to acquire first color information of eachpixel in the image with the first rendering style; a searching unit,configured to search for second color information corresponding to thefirst color information of each pixel in a relationship table of colortransformation for transforming the first rendering style into thesecond rendering style; and a first generating unit, configured togenerate the image with the second rendering style based on the secondcolor information corresponding to the first color information of eachpixel.

In some embodiments, the first determining unit is specificallyconfigured to: search for the relationship table of color transformationcorresponding to the first rendering style and the second renderingstyle in a correspondence among an original rendering style, a targetrendering style, and a relationship table of color transformation withthe first rendering style as the original rendering style and the secondrendering style as the target rendering style.

In some embodiments, the first preset processing model is a neuralnetwork model for acquiring the image with the second rendering style;and the second acquiring module 12 includes: a processing unit,configured to acquire the image with the second rendering style byprocessing the image with the first rendering style by using the neuralnetwork model.

In some embodiments, the second determining unit is specificallyconfigured to: search for the neural network model corresponding to thesecond rendering style in a correspondence between a rendering style anda neural network model for acquiring an image with the rendering style.

In some embodiments, the second acquiring module 12 includes: a secondacquiring unit, configured to acquire a preset image with the secondrendering style; a second generating unit, configured to generate areference image; and an iteration unit, configured to perform at leastone round of optimal iteration on the reference image by using aniterative optimization algorithm, based on the image with the firstrendering style and the preset image with the second rendering style;and determine a reference image on which the optimal iteration has beenperformed as the image with the second rendering style, when adifference between a rendering style of the reference image and thesecond rendering style is less than a first preset threshold and adifference between image content of the reference image and imagecontent of the image with the first rendering style is less than asecond preset threshold.

In some embodiments, the first generating module 13 includes: a thirdacquiring unit, configured to acquire first color information of a pixelin the location in the image with the first rendering style and secondcolor information of a pixel in the location in the image with thesecond rendering style, for each same location in the image with thefirst rendering style and the image with the second rendering style; athird determining unit, configured to determine at least one piece oftarget color information of a pixel in the location based on the firstcolor information, the second color information, a preset firstrendering style coefficient, and a preset second rendering stylecoefficient; a third generating unit, configured to generate at leastone candidate image based on the at least one piece of target colorinformation of a pixel in each location; and a fourth determining unit,configured to determine the at least one first intermediate gradientimage based on the at least one candidate image.

In some embodiments, the fourth determining unit includes: a determiningsubunit, configured to determine the at least one candidate image as theat least one first intermediate gradient image; or an acquiring subunit,configured to acquire a local processing manner based on the firstrendering style and the second rendering style, and a processingsubunit, configured to acquire the at least one first intermediategradient image by processing the at least one candidate image accordingto the local processing manner.

In some embodiments, the acquiring subunit is specifically configured tosearch for the local processing manner corresponding to the firstrendering style and the second rendering style in a correspondence amongan original rendering style, a target rendering style, and a localprocessing manner, with the first rendering style as the originalrendering style and the second rendering style as the target renderingstyle.

In some embodiments, the apparatus further includes: a fourth acquiringmodule, configured to acquire an image with a third rendering stylebased on the image with the second rendering style and the first presetprocessing model; a fourth generating module, configured to generate atleast one second intermediate gradient image based on the image with thesecond rendering style, the image with the third rendering style, andthe second preset processing model, where the at least one secondintermediate gradient image includes an image in a gradient process fromthe image with the second rendering style to the image with the thirdrendering style; a fifth generating module, configured to generate asecond gradient video based on the image with the second renderingstyle, the at least one second intermediate gradient image, and theimage with the third rendering style; and a combination module,configured to combine the first gradient video and the second gradientvideo into a third gradient video.

In this application, the image with the first rendering style isacquired; the image with the second rendering style is acquired based onthe image with the first rendering style and the first preset processingmodel; the at least one first intermediate gradient image is generatedbased on the image with the first rendering style, the image with thesecond rendering style, and the second preset processing model; wherethe at least one first intermediate gradient image includes the image inthe gradient process from the image with the first rendering style tothe image with the second rendering style; and the first gradient videois generated based on the image with the first rendering style, the atleast one first intermediate gradient image, and the image with thesecond rendering style. According to this application, when a userrequires to acquire a gradient video, the user does not require to spenda long time in continuously shooting the gradient video by using acamera, and can acquire the gradient video in the manner in thisapplication only by capturing one image, thereby improving efficiency ofacquiring a gradient video and improving user experience.

For the apparatus in the foregoing embodiments, specific manners ofperforming operations by the modules have been described in detail inthe embodiments related to the method, and details are not describedherein again.

FIG. 3 illustrates a block diagram of an electronic device 800 accordingto this application. For example, the electronic device 800 may be amobile phone, a computer, a digital broadcasting terminal, a messagetransceiver device, a game console, a tablet device, a medical device,fitness equipment, a personal digital assistant, or the like.

Referring to FIG. 3, the electronic device 800 may include one or moreof the following components: a processing component 802, a memory 804, apower supply component 806, a multimedia component 808, an audiocomponent 810, an input/output (I/O) interface 812, a sensor component814, and a communication component 816.

The processing component 802 usually controls an overall operation ofthe electronic device 800, for example, operations associated withdisplaying, calling, data communication, camera operations, andrecording operations. The processing component 802 may include one ormore processors 820, to execute an instruction, to complete all or somesteps of the method. In addition, the processing component 802 mayinclude one or more modules, facilitating interaction between theprocessing component 802 and the other components. For example, theprocessing component 802 may include a multimedia module, facilitatinginteraction between the multimedia component 808 and the processingcomponent 802.

The memory 804 is configured to store various types of data, to supportoperations of the device 800. An example of the data includes aninstruction of any application or method operated in the electronicdevice 800, contact data, address book data, a message, an image, avideo, and the like. The memory 804 may be implemented by any type ofvolatile or non-volatile storage devices or a combination thereof, forexample, a static random access memory (SRAM), an electrically erasableprogrammable read-only memory (EEPROM), an erasable programmableread-only memory (EPROM), a programmable read-only memory (PROM), aread-only memory (ROM), a magnetic memory, a flash memory, a magneticdisk, or an optical disc.

The power supply component 806 supplies power to various components ofthe electronic device 800. The power supply component 806 may include apower supply management system, one or more power supplies, and othercomponents associated with generating electricity for, managingelectricity for, and supplying electricity to the electronic device 800.

The multimedia component 808 includes a screen providing an outputinterface between the electronic device 800 and a user. In someembodiments, the screen may include a liquid crystal display (LCD) and atouch panel (TP). If the screen includes the touch panel, the screen maybe implemented as a touch screen, to receive an input signal from theuser. The touch panel includes one or more touch sensors, to sensetouching, sliding, and a gesture on the touch panel. The touch sensornot only may sense a boundary of a touch or sliding operation, but alsomay detect duration and pressure related to the touch or slidingoperation. In some embodiments, the multimedia component 808 includes afront-facing camera and/or rear-facing camera. When the device 800 is anoperation mode, such as a photographing mode or a video mode, thefront-facing camera and/or the rear-facing camera may receive externalmultimedia data. Each of the front-facing camera and the rear-facingcamera may be a fixed optical lens system or have a focal length and anoptical zooming capability.

The audio component 810 is configured to output and/or input an audiosignal. For example, the audio component 810 includes a microphone(MIC). When the electronic device 800 is in an operation mode, such as acalling mode, a recording mode, and a speech recognition mode, themicrophone is configured to receive the external audio signal. Thereceived audio signal may be further stored in the memory 804 or sent byusing the communication component 816. In some embodiments, the audiocomponent 810 further includes a loudspeaker, configured to output theaudio signal.

The I/O interface 812 provides an interface between the processingcomponent 802 and a peripheral interface module, and the peripheralinterface module may be a keyboard, a click wheel, buttons, or the like.The buttons include, but not limited to, a home page button, a volumebutton, a start button, and a lock button.

The sensor component 814 includes one or more sensors, and is configuredto provide status estimation in various aspects for the electronicdevice 800. For example, the sensor component 814 may detect an on/offstate of the device 800 and relative positioning of a component. Forexample, the component is a display and a keypad of the electronicdevice 800. The sensor component 814 may further detect a locationchange of the electronic device 800 or a component of the electronicdevice 800, detect whether there is contact between the user and theelectronic device 800, and detect an orientation or acceleration/slowingdown of the electronic device 800 and a temperature change of theelectronic device 800. The sensor component 814 may include a proximitysensor, configured to detect existence of a nearby object when there isno physical contact. The sensor component 814 may further include anoptical sensor, such as a CMOS or CCD image sensor, used in an imagingapplication. In some embodiments, the sensor component 814 may furtherinclude an acceleration sensor, a gyroscope sensor, a magnetic sensor, apressure sensor, or a temperature sensor.

The communication component 816 is configured to facilitate wired orwireless communication between the electronic device 800 and otherdevices. The electronic device 800 may access a wireless network basedon a communication standard, such as Wi-Fi, an operator network (such as2G, 3G, 4G, or 5G), or a combination thereof. In some embodiments, thecommunication component 816 receives, through a broadcast channel, abroadcast signal or broadcast-related information from an externalbroadcasting management system. In some embodiments, the communicationcomponent 816 further includes a near field communication (NFC) module,to facilitate short-range communication. For example, the NFC module maybe implemented based on a radio frequency identification (RFID)technology, an infrared data association (IrDA) technology, anultra-wideband (UWB) technology, a Bluetooth (BT) technology, and othertechnologies.

In some embodiments, the electronic device 800 may be implemented byusing one or more application-specific integrated circuits (ASIC), oneor more digital signal processors (DSP), one or more digital signalprocessing devices (DSPD), one or more programmable logic devices (PLD),one or more field programmable gate arrays (FPGA), one or morecontrollers, one or more microcontrollers, one or more microprocessors,or one or more other electronic elements, to perform the foregoingmethod.

In some embodiments, a non-temporary computer readable storage mediumincluding an instruction is further provided, such as the memory 804including the instruction. The instruction may be executed by theprocessor 802 of the electronic device 800 to complete the foregoingmethod. For example, the non-temporary computer readable storage mediummay be an ROM, a random access memory (RAM), a CD-ROM, a magnetic tape,a floppy disk, or an optical data storage device.

In some embodiments, a computer program product is further provided. Thecomputer program product may be stored in the memory 804, and when aninstruction in the computer program product is executed by the processor820 of the electronic device 800, the electronic device 800 is enabledto perform the image processing method.

FIG. 4 illustrates a block diagram of an electronic device 1900according to this application. For example, the electronic device 1900may be provided as a server.

Referring to FIG. 4, the electronic device 1900 includes a processingcomponent 1922, and further includes one or more processors, and amemory resource represented by a memory 1932, configured to store aninstruction that can be executed by the processing component 1922, suchas an application. The application stored in the memory 1932 may includeone or more modules, where each module corresponds to one group ofinstructions. In addition, the processing component 1922 is configuredto execute the instruction, to perform the foregoing method.

The electronic device 1900 may further include a power supply component1926, configured to execute power supply management for the electronicdevice 1900; a wired or wireless network interface 1950, configured toconnect the electronic device 1900 to a network; and an input/output(I/O) interface 1958. The electronic device 1900 may be operated basedon an operating system stored in the memory 1932, such as WindowsServer™, Mac OS X™, Unix™, Linux™, FreeBSD™, or a similar operatingsystem.

We claim:
 1. A method for processing an image, comprising: acquiring animage with a first rendering style and an image with a second renderingstyle; generating at least one first intermediate gradient image basedon the image with the first rendering style and the image with thesecond rendering style; wherein the at least one first intermediategradient image comprises an image in a gradient process from the imagewith the first rendering style to the image with the second renderingstyle; and generating a first gradient video based on the image with thefirst rendering style, the at least one first intermediate gradientimage, and the image with the second rendering style.
 2. The methodaccording to claim 1, wherein said acquiring the image with the secondrendering style comprises: acquiring first color information of eachpixel in the image with the first rendering style; searching for secondcolor information corresponding to the first color information of eachpixel in a relationship table of color transformation for transformingthe first rendering style into the second rendering style; andgenerating the image with the second rendering style based on the secondcolor information corresponding to the first color information of eachpixel.
 3. The method according to claim 2, said generating the imagewith the second rendering style comprises: generating a blank image ofsame resolution as the image with the first rendering style; determininga location of each pixel in the blank image based on a location of eachpixel in the image with the first rendering style; and generating theimage with the second rendering style by filling respective locations ofthe pixels in the blank image with the second color informationcorresponding to the first color information of the pixels.
 4. Themethod according to claim 2, further comprises: determining therelationship table of color transformation for transforming the firstrendering style into the second rendering style; said determining therelationship table of color transformation comprises: searching for therelationship table of color transformation corresponding to the firstrendering style and the second rendering style in a correspondence amongan original rendering style, a target rendering style, and arelationship table of color transformation, with the first renderingstyle as the original rendering style and the second rendering style asthe target rendering style.
 5. The method according to claim 1, whereinsaid acquiring the image with the second rendering style comprises:acquiring a preset image with the second rendering style; generating areference image; performing at least one round of optimal iteration onthe reference image through an iterative optimization algorithm, basedon the image with the first rendering style and the preset image withthe second rendering style; and determining a reference image on whichthe optimal iteration has been performed as the image with the secondrendering style, in response to a difference between a rendering styleof the reference image and the second rendering style being less than afirst threshold and a difference between image content of the referenceimage and image content of the image with the first rendering stylebeing less than a second threshold.
 6. The method according to claim 1,wherein said generating the at least one first intermediate gradientimage comprises: for each same location in the image with the firstrendering style and the image with the second rendering style, acquiringfirst color information of a pixel in the location in the image with thefirst rendering style and second color information of a pixel in thelocation in the image with the second rendering style, and determiningat least one piece of target color information of a pixel in thelocation based on the first color information, the second colorinformation, a first rendering style coefficient, and a second renderingstyle coefficient; generating at least one candidate image based on theat least one piece of target color information of a pixel in eachlocation; and determining the at least one first intermediate gradientimage based on the at least one candidate image.
 7. The method accordingto claim 6, wherein said determining the at least one first intermediategradient image comprises: determining the at least one candidate imageas the at least one first intermediate gradient image; or, determiningthe at least one first intermediate gradient image by acquiring a localprocessing manner based on the first rendering style and the secondrendering style and processing the at least one candidate image based onthe local processing manner.
 8. The method according to claim 7, whereinsaid acquiring the local processing manner comprises: searching for thelocal processing manner corresponding to the first rendering style andthe second rendering style in a correspondence among an originalrendering style, a target rendering style, and a local processingmanner, with the first rendering style as the original rendering styleand the second rendering style as the target rendering style.
 9. Themethod according to claim 1, further comprising: acquiring an image witha third rendering style based on the image with the second renderingstyle; generating at least one second intermediate gradient image basedon the image with the second rendering style and the image with thethird rendering style; wherein the at least one second intermediategradient image comprises an image in a gradient process from the imagewith the second rendering style to the image with the third renderingstyle; generating a second gradient video based on the image with thesecond rendering style, the at least one second intermediate gradientimage, and the image with the third rendering style; and generating athird gradient video by combining the first gradient video and thesecond gradient video.
 10. An electronic device, comprising: aprocessor; and a memory configured to store an instruction executed bythe processor; wherein in response to the instruction being executed,the processor is configured to: acquire an image with a first renderingstyle and an image with a second rendering style; generate at least onefirst intermediate gradient image based on the image with the firstrendering style and the image with the second rendering style; whereinthe at least one first intermediate gradient image comprises an image ina gradient process from the image with the first rendering style to theimage with the second rendering style; and generate a first gradientvideo based on the image with the first rendering style, the at leastone first intermediate gradient image, and the image with the secondrendering style.
 11. The electronic device according to claim 10,wherein the processor is configured to: acquire first color informationof each pixel in the image with the first rendering style; search forsecond color information corresponding to the first color information ofeach pixel in a relationship table of color transformation fortransforming the first rendering style into the second rendering style;and generate the image with the second rendering style based on thesecond color information corresponding to the first color information ofeach pixel.
 12. The electronic device according to claim 11, wherein theprocessor is configured to: generate a blank image of same resolution asthe image with the first rendering style; determine a location of eachpixel in the blank image based on a location of each pixel in the imagewith the first rendering style; and generate the image with the secondrendering style by filling respective locations of the pixels in theblank image with the second color information corresponding to the firstcolor information of the pixels.
 13. The electronic device according toclaim 11, wherein the processor is configured to: determine therelationship table of color transformation for transforming the firstrendering style into the second rendering style; wherein the processoris further configured to: search for the relationship table of colortransformation corresponding to the first rendering style and the secondrendering style in a correspondence among an original rendering style, atarget rendering style, and a relationship table of colortransformation, with the first rendering style as the original renderingstyle and the second rendering style as the target rendering style. 14.The electronic device according to claim 10, wherein the processor isconfigured to: acquire a preset image with the second rendering style;generate a reference image; perform at least one round of optimaliteration on the reference image through an iterative optimizationalgorithm, based on the image with the first rendering style and thepreset image with the second rendering style; and determine a referenceimage on which the optimal iteration has been performed as the imagewith the second rendering style, in response to a difference between arendering style of the reference image and the second rendering stylebeing less than a first threshold and a difference between image contentof the reference image and image content of the image with the firstrendering style being less than a second threshold.
 15. The electronicdevice according to claim 10, wherein the processor is configured to:for each same location in the image with the first rendering style andthe image with the second rendering style, acquire first colorinformation of a pixel in the location in the image with the firstrendering style and second color information of a pixel in the locationin the image with the second rendering style, and determine at least onepiece of target color information of a pixel in the location based onthe first color information, the second color information, a firstrendering style coefficient, and a second rendering style coefficient;generate at least one candidate image based on the at least one piece oftarget color information of a pixel in each location; and determine theat least one first intermediate gradient image based on the at least onecandidate image.
 16. The electronic device according to claim 15,wherein the processor is configured to: determine the at least onecandidate image as the at least one first intermediate gradient image;or, determine the at least one first intermediate gradient image byacquiring a local processing manner based on the first rendering styleand the second rendering style and processing the at least one candidateimage based on the local processing manner.
 17. The electronic deviceaccording to claim 16, wherein the processor is configured to: searchfor the local processing manner corresponding to the first renderingstyle and the second rendering style in a correspondence among anoriginal rendering style, a target rendering style, and a localprocessing manner, with the first rendering style as the originalrendering style and the second rendering style as the target renderingstyle.
 18. The electronic device according to claim 10, wherein theprocessor is configured to: acquire an image with a third renderingstyle based on the image with the second rendering style; generate atleast one second intermediate gradient image based on the image with thesecond rendering style and the image with the third rendering style;wherein the at least one second intermediate gradient image comprises animage in a gradient process from the image with the second renderingstyle to the image with the third rendering style; generate a secondgradient video based on the image with the second rendering style, theat least one second intermediate gradient image, and the image with thethird rendering style; and generate a third gradient video by combiningthe first gradient video and the second gradient video.
 19. Anon-temporary computer readable storage medium, wherein in response toan instruction in the storage medium being executed by a processor of anelectronic device, the electronic device is enabled to: acquire an imagewith a first rendering style and an image with a second rendering style;generate at least one first intermediate gradient image based on theimage with the first rendering style and the image with the secondrendering style; wherein the at least one first intermediate gradientimage comprises an image in a gradient process from the image with thefirst rendering style to the image with the second rendering style; andgenerate a first gradient video based on the image with the firstrendering style, the at least one first intermediate gradient image, andthe image with the second rendering style.